package org.extremengine.demo;

import java.awt.Graphics;

import org.extremengine.common.RigidBody;
import org.extremengine.common.Velocity;
import org.extremengine.shape.Circle;
import org.extremengine.shape.ParallelRectangle;

public class PanelAirCollide extends BasePanelWorld {

	RigidBody ball;
	RigidBody ball2;
	RigidBody box;

	public PanelAirCollide(DemoCallback demoCallback) {
		super(demoCallback);
	}

	@Override
	public void initDemoWorld() {
		super.initDemoWorld();
		
		world.setGravityAccelaration(0);
		ground.setElasticity(1.0);
		ceiling.setElasticity(1.0);
		wallLeft.setElasticity(1.0);
		wallRight.setElasticity(1.0);
		
		ball = world.createRigidBody(new Object(), 0, 1.0, 20, new Circle(45, 25, 3));
		ball.setV(new Velocity(10, 190));
		
		ball2 = world.createRigidBody(new Object(), 0, 1.0, 20, new Circle(10, 23, 3));
		ball2.setV(new Velocity(12, 350));
		
		box = world.createRigidBody(new Object(), 0, 1.0, 40, new ParallelRectangle(20, 40, 2, 10));
		box.setV(new Velocity(5, 90));
		
		//		box.setMovable(false);


	}

//	@Override
//	protected void handleCollision(long t, RigidBody rb1, RigidBody rb2) {
//		super.handleCollision(t, rb1, rb2);
//		world.pause(1000);
////		try {
////			Thread.currentThread().sleep(1000);
////		} catch (InterruptedException e) {
////			e.printStackTrace();
////		}
//		world.resume();
//	}

	@Override
	public void paint(Graphics g) {
		super.paint(g);
		if (!world.isRunning()) {
			this.drawRigidBody(g, ball);
			this.drawRigidBody(g, ball2);
			this.drawRigidBody(g, box);
		}
	}

}
